﻿using System;
using System.Collections.Generic;
using IView.ITaskFunctional;
using Engine;
using System.Windows.Forms;
using DataTransferObject;

namespace Presenter.TaskFunctionalPresenter
{
    public class PresenterTaskManagerForm: Presenter
    {
        #region Attributes
        private ITaskManager _iTaskManager;
        private JskeEngine jskeEngine;
        #endregion

        #region Static fields
        public static string[] DETAIL_COLUMNS = { "Task name", "Total work", "Priority", "Scheduled start", "Scheduled end" };
        public static int[] COLUMNS_WIDTH = { 150, 50, 50, 100, 100 };
        #endregion

        public PresenterTaskManagerForm(ITaskManager taskManager, int dataAccessMode)
        {
            Presenter.changeDataServiceMode(dataAccessMode);
            _iTaskManager = taskManager;
            jskeEngine = JskeEngine.getInstance(dataServiceMode);
            _iTaskManager.PopulaterMyTasks(jskeEngine.TaskList.GetTaskList);
        }

        public List<ListViewGroup> GroupOfProjects()
        {
            List<ListViewGroup> listViewGroups = new List<ListViewGroup>();
            List<string> projectNames = jskeEngine.SystemConfiguration.TabProjectData.ListProjectName;
            foreach (string projectName in projectNames)
            {
                ListViewGroup lg = new ListViewGroup(projectName);
                listViewGroups.Add(lg);
            }
            return listViewGroups;
        }

        public List<ListViewGroup> GroupOfWorkingHour()
        {
            List<ListViewGroup> whGroups = new List<ListViewGroup>();
            List<WorkingHourItem> listOfwhItems = jskeEngine.SystemConfiguration.TabWorkingHoursData.ListOfWorkingHourItems;
            foreach (WorkingHourItem whItem in listOfwhItems)
            {
                ListViewGroup lg = new ListViewGroup(whItem.WorkingHourName);
                lg.Tag = whItem.WorkingHourID;
                whGroups.Add(lg);
            }
            return whGroups;
        }

        public void AddTaskToEngine(Task t)
        {
            jskeEngine.AddTaskToTaskList(t);
        }
    }
}
